Skip to content

Conversation

@Siddharth2207
Copy link
Contributor

@Siddharth2207 Siddharth2207 commented Oct 29, 2025

Motivation

IAU Price Feed

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • New Features

    • Added support for iShares Gold Trust (IAU) as a recognized price feed.
  • Tests

    • Extended test coverage to validate IAU symbol mapping and known/unknown mappings.
    • Added a price retrieval test for IAU including max-age validation and expected price/confidence values.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 29, 2025

Walkthrough

Adds a new Pyth price feed for iShares Gold Trust (Equity.US.IAU/USD): two constants (ID and symbol IntOrAString) and a getPriceFeedId branch; tests updated/added to cover the new constant, mapping, and price retrieval.

Changes

Cohort / File(s) Summary
Core price feed addition
src/lib/pyth/LibPyth.sol
Added PRICE_FEED_ID_EQUITY_US_IAU_USD (bytes32) and PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_IAU_USD (uint256); extended getPriceFeedId to return the new ID for the IAU symbol.
Constants tests
test/src/lib/pyth/LibPyth.constants.t.sol
Added assertion verifying IntOrAString conversion for Equity.US.IAU/USD.
Lookup tests
test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol
Added known mapping assertion for Equity.US.IAU/USD and excluded it from unknown mappings.
Price retrieval tests
test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol
Added test calling checkPriceNoOlderThan for Equity.US.IAU/USD (maxAge 24h) with expected price/confidence values.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Caller as Contract/Test
    participant LibPyth as LibPyth.getPriceFeedId
    note over LibPyth `#E8F0FF`: Symbol-to-ID lookup (extended)
    Caller->>LibPyth: request ID for symbol (IntOrAString)
    alt matches Equity.US.IAU/USD
        LibPyth-->>Caller: PRICE_FEED_ID_EQUITY_US_IAU_USD
    else matches other known symbol
        LibPyth-->>Caller: corresponding PRICE_FEED_ID_*
    else unknown
        LibPyth-->>Caller: revert / not found
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Additive, homogeneous change (constants + single branching case).
  • Review focus: correct constant values, IntOrAString encoding, and updated tests.

Possibly related PRs

  • feed ids #10 — Similar edits to LibPyth.sol adding price-feed constants and lookup branches (related pattern).
  • 2025 06 10 literal intorastring #1 — Extended IntOrAString symbol constants and getPriceFeedId mappings; continuation of the same approach.
  • GME, MSTR, SPLG, BRK-B feed #3 — Adds PRICE_FEED_ID/PRICE_FEED_SYMBOL constants and extends getPriceFeedId for additional equity feeds.

Suggested reviewers

  • hardyjosh

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'IAU Price Feed' directly relates to the main change: adding support for iShares Gold Trust (IAU) price feed constants and lookup logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2025-10-29-iau

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e0404b and ad9f77b.

⛔ Files ignored due to path filters (1)
  • src/generated/PythWords.pointers.sol is excluded by !**/generated/**
📒 Files selected for processing (4)
  • src/lib/pyth/LibPyth.sol (2 hunks)
  • test/src/lib/pyth/LibPyth.constants.t.sol (1 hunks)
  • test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol (2 hunks)
  • test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: git-clean
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-static)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-legal)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-test)
🔇 Additional comments (6)
test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol (2)

77-80: LGTM!

The assertion correctly tests the IAU price feed mapping following the established pattern for other equity feeds.


101-101: LGTM!

Correctly excludes IAU from the unknown mappings fuzz test, maintaining test validity.

test/src/lib/pyth/LibPyth.constants.t.sol (1)

80-83: LGTM!

The assertion correctly validates the IAU IntOrAString constant against the string conversion, following the established testing pattern.

src/lib/pyth/LibPyth.sol (2)

170-171: LGTM!

The getPriceFeedId branch correctly maps the IAU symbol to its feed ID, following the established pattern.


117-122: I need to determine which chain(s) this Solidity library targets. Let me search for the IAU/USD feed ID on the most common EVM chains where Pyth operates.

Let me search for Pyth's specific price feed IDs, particularly for commodities and equities like IAU.

Let me search for Pyth's official price feed ID documentation or GitHub repository.

Let me search one more time to directly verify if the IAU feed ID is correct or documented anywhere.

Verify the Pyth price feed ID against Pyth's official documentation.

The IntOrAString encoding of the constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_IAU_USD is correctly formatted. However, I could not independently verify that the feed ID 0xf703fbded84f7da4bd9ff4661b5d1ffefa8a9c90b7fa12f247edc8251efac914 is correct for Equity.US.IAU/USD through publicly available sources.

Before merging, confirm this feed ID matches the official Pyth Network price feed ID for IAU/USD on the target chain(s) by checking the Pyth Price Feed IDs page for all supported assets.

test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol (1)

184-189: Verification of hard-coded test values requires test execution.

The IAU price test (lines 184-189) follows the correct pattern and structure. The expected values (price: 71.99028 USD, conf: 0.07147 USD) are plausible for a gold ETF. However, this is a snapshot test where hard-coded values must exactly match the on-chain Pyth feed state at FORK_BLOCK_BASE (36353737 on Base chain).

Confirmation requires running forge test --match-test testPriceNoOlderThanBase -vv to verify the values are current and correct. This should be done before merging to ensure the test reflects accurate historical prices.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Siddharth2207 Siddharth2207 self-assigned this Oct 29, 2025
@thedavidmeister thedavidmeister merged commit 5a85ac1 into main Nov 7, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants